package com.quantdo.demo.edit;

import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;

import com.quantdo.demo.date.TableDate;

public class TableSort extends ViewerSorter{

	private int column;

	public void doSort(int column){
		this.column = column;
	}
	
	@Override
	public int compare(Viewer viewer, Object e1, Object e2) {
		TableDate tableDate = (TableDate)e1;
		TableDate tableDate2 = (TableDate)e2;
		switch (column) {
		case 1:{
			String str1 = tableDate.getId();
			String str2 = tableDate2.getId();
			return str1.compareTo(str2);
		}
		case 2:{
			String str1 = tableDate.getName();
			String str2 = tableDate2.getName();
			return str1.compareTo(str2);
		}
		default:
			break;
		}
		return super.compare(viewer, e1, e2);
	}
	
}
